home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / bin / ecryptfs-umount-private < prev    next >
Encoding:
Text File  |  2009-06-04  |  797 b   |  29 lines

  1. #!/bin/sh -e
  2. # This script unmounts a user's private ecryptfs folder
  3. # and clears the kernel keyring of the relevant keys
  4. #
  5. # Original by Michael Halcrow, IBM
  6. # Extracted to a stand-alone script by Dustin Kirkland <kirkland@canonical.com>
  7.  
  8. if grep -qs "$HOME/.Private $PWD ecryptfs " /proc/mounts 2>/dev/null; then
  9.     pwd_mounted=1
  10. fi
  11. out=`/sbin/umount.ecryptfs_private 2>&1`
  12. if [ -n "$out" ]; then
  13.     echo "$out"
  14. fi
  15. if echo "$out" | grep -q -v "Sessions still open"; then
  16.     for sig in `cat "$HOME/.ecryptfs/Private.sig"`; do
  17.         key_id=`keyctl show | grep "$sig$" | awk '{print $1}'`
  18.         keyctl unlink "$key_id" @u
  19.     done
  20. fi
  21. if [ "$pwd_mounted" = "1" ]; then
  22.     echo
  23.     echo "INFO: Your private directory has been unmounted."
  24.     echo "INFO: To see this change in your current shell:"
  25.     echo "  cd $PWD"
  26.     echo
  27. fi
  28.  
  29.